package com.his.dictusageitem.service.Imp;

import com.his.dictusageitem.dao.DictUsageItemMapper;
import com.his.dictusageitem.entity.DictUsageItem;
import com.his.dictusageitem.entity.DictUsageItemKey;
import com.his.dictusageitem.entity.DictUsageItem_Detailed;
import com.his.dictusageitem.service.DictUsageItemService;
import com.his.dictusageitem.vo.DictUsageItemVo;
import com.his.login.entity.DictEmployee;
import com.xiao.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class DictUsageItemServiceImpl implements DictUsageItemService {

    @Autowired
    private DictUsageItemMapper dictUsageItemMapper;
    @Override
    public List<DictUsageItem_Detailed> selectByUsageID(DictEmployee dictEmployee, String usageID) {
        DictUsageItem dictUsageItem=new DictUsageItem();
        dictUsageItem.setUsageid(usageID);
        dictUsageItem.setHospid(dictEmployee.getHOSPID());
        return dictUsageItemMapper.selectByUsageID(dictUsageItem);
    }

    @Override
    public void insert(DictEmployee dictEmployee, DictUsageItemVo dictUsageItemVo) {
        DictUsageItem dictUsageItem= BeanUtil.copyBean(dictUsageItemVo,DictUsageItem.class);
        dictUsageItem.setHospid(dictEmployee.getHOSPID());
        dictUsageItemMapper.insert(dictUsageItem);
    }

    @Override
    public void delete(DictUsageItemVo dictUsageItemVo) {
        DictUsageItemKey dictUsageItemKey= BeanUtil.copyBean(dictUsageItemVo, DictUsageItemKey.class);
        dictUsageItemMapper.deleteByPrimaryKey(dictUsageItemKey);
    }
}
